<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>登录页面 -药品生产变更管理平台</title>
<link rel="icon" href="<%=path%>/images/favicon.ico" type="image/ico">
<meta name="author" content="guowenjie">
<link href="<%=path%>/css/bootstrap.min.css" rel="stylesheet">
<link href="<%=path%>/css/materialdesignicons.min.css" rel="stylesheet">
<link href="<%=path%>/css/style.min.css" rel="stylesheet">
<link rel="stylesheet" href="<%=path%>/js/ion-rangeslider/ion.rangeSlider.min.css">
<link href="<%=path%>/js/jconfirm/jquery-confirm.min.css" rel="stylesheet">
<link href="<%=path%>/js/bootstrap-datepicker/bootstrap-datepicker3.min.css" rel="stylesheet">
<link href="<%=path%>/js/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<link href="<%=path%>/css/materialdesignicons.min.css" rel="stylesheet">
<script type="text/javascript" src="<%=path%>/js/jquery.min.js"></script>
 <script type="text/javascript" src="<%=path%>/js/main.min.js"></script>
<script src="<%=path%>/js/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>
<script src="<%=path%>/js/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/bootstrap-table/bootstrap-table.js"></script>
<script type="text/javascript" src="<%=path%>/js/bootstrap-table/bootstrap-table-zh-CN.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/jconfirm/jquery-confirm.min.js"></script>

</head>
 <div class="container-fluid p-t-15">
    
        <div  class="card">
      <div class="card-body">
        <div class="row">
        
         
        
          <div class="col-md-12">
          <div id="toolbar" class="toolbar-btn-action">
            <div class="col-xs-12">
            <label class="lyear-radio radio-inline radio-primary">
              <input type="radio" name="e1"  value = "0"><span>全部</span>
            </label>
            <label class="lyear-radio radio-inline radio-primary">
              <input type="radio" name="e1" checked value = "1"><span>未审核</span>
            </label>
           <label class="lyear-radio radio-inline radio-primary">
              <input type="radio" name="e1" value = "2"><span>已审核</span>
            </label>
          </div> 
            
          </div>
           <table id="tb_hhhtxx" ></table>
        </div>
         
            
        </div>
        
      </div></div></div>
      <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
            <div class="modal-dialog" role="document">
              <div class="modal-content">
                <div class="modal-header">
                  <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                  <h4 class="modal-title" id="exampleModalLabel">审核数据</h4>
                </div>
                <div class="modal-body">
                  <form>
                    <div class="form-group">
                     <div class="example-box">
            <label class="lyear-radio radio-inline radio-primary">
              <input type="radio" name="e" checked value="1"><span>通过</span>
            </label>
            <label class="lyear-radio radio-inline radio-primary">
              <input type="radio" name="e" value="2"><span>不通过</span>
            </label>
           
          </div></div>
                    <div class="form-group">
                      <label for="message-text" id="wj" class="control-label">账号：</label>
                      <input type="text" class="form-control" id="usercode"></input>
                      <label id="ts" Style="color:red;padding-left: 38px"></label>
                    </div>
                  </form>
                </div>
                <div class="modal-footer">
                  <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                  <button type="button" onclick="savesqsq();" class="btn btn-primary">保存数据</button>
                </div>
              </div>
            </div>
          </div>
       <script type="text/javascript">
       var xzwjlx = 1;
       $('input[type=radio][name=e1]').change(function () {
   	     xzwjlx = $('input:radio[name="e1"]:checked').val();
   	    cxsj();
   	});
       
       
       $('input[type=radio][name=e]').change(function () {
     	   let  a = $('input:radio[name="e"]:checked').val();
     	  let label=document.getElementById("wj");
     	    
     	   if(a==1){
     		   
     		  label.innerText="账号：";
     		   
     	   }else{
     		  label.innerText="拒绝理由：";   
     		   
     	   }
     	});
       
       var xzsj;
       function savesqsq(){
    	   let lx = $('input:radio[name="e"]:checked').val();
    	   let usercode = $("#usercode").val();
    	   if(lx==1 && usercode == ""){
    		   
    		   $.alert("请填写帐号"); 
    	   }else{
    		   
    		   
    		   if(lx==1){
    			   
    		  
    		   $.ajax({
  	   			 type: "post",//方法类型
  	   		    dataType: "json",//预期服务器返回的数据类型 jsonp跨域
  	   			url: "<%=path%>/admin/newuser",
  	   			 data:{
  	   				"username":xzsj.name,
  	   				"usercode":usercode,
  	   				"RoleID":3
  	   			}, 
  	   			success: function(req) {
  	   		
  	   		    if(req.code == 0){
  	   		   	
  	   		   $.ajax({
 	   			 type: "post",//方法类型
 	   		    dataType: "json",//预期服务器返回的数据类型 jsonp跨域
 	   			url: "<%=path%>/admin/shsqsj",
 	   		    data:{
	   				"password":req.msg,
	   				"id":xzsj.id,
	   				"email":xzsj.email,
	   				 "jg":lx,
	   				"usercode":usercode
	   			}, 
	   			success: function(req) {
	   			 $("#exampleModal").modal('hide');
	   			  cxsj();
	   			},error: function(e){ 
	  	   			 console.log(e.responseText);	
	  	   			 $('#ts').html("保存失败，数据异常！");	
	  	   			 
	  	   			}
	  	   		});
  	   		    
     	   			    
     	   		}else{
  	   		    	$('#ts').html(req.msg);		
  	   		    	
  	   		    }		
  	   		
  	   		  
  	   				 
  	   			},error: function(e){ 
  	   			 console.log(e.responseText);	
  	   			 $('#ts').html("保存失败，数据异常！");	
  	   			 
  	   			}
  	   		});
    		   
    		   }else{
    			   $.ajax({
    	 	   			 type: "post",//方法类型
    	 	   		    dataType: "json",//预期服务器返回的数据类型 jsonp跨域
    	 	   			url: "<%=path%>/admin/shsqsj",
    	 	   		    data:{
    		   				"id":xzsj.id,
    		   				 "jg":lx,
    		   				"usercode":usercode,
    		   				"email":xzsj.email
    		   			}, 
    		   			success: function(req) {
    		   			 $("#exampleModal").modal('hide');
    		   			  cxsj();
    		   			},error: function(e){ 
    		  	   			 console.log(e.responseText);	
    		  	   			 $('#ts').html("保存失败，数据异常！");	
    		  	   			 
    		  	   			}
    		  	   		});  
    			   
    			   
    		   }  
    		   
    		   
    	   }
    	   
    	   $("#usercode").val("");
       }
       
       
       cxsj();
       function cxsj(){
    	   
    	   $.ajax({
  			 type: "POST",//方法类型
  		    dataType: "json",//预期服务器返回的数据类型
  			url: "<%=path%>/admin/getsqxx",
  			 data:{
  			"xzwjlx":xzwjlx
  			}, 
  			success: function(req) {	
  			
  				let data = req.data;
  				$("#tb_hhhtxx").bootstrapTable('refreshOptions',{data:data});
  			},error: function(){ 
  				
  				
  			}
  		}); 
    	   
    	   
       }
       
       function showpdf(filename){
          	
         	 
           $.ajax({
       		 type: "post",//方法类型
       	    dataType: "json",//预期服务器返回的数据类型 jsonp跨域
       		url: "<%=path%>/bg/findwj",
       		 data:{
       			"filename":filename
       		}, 
       		success: function(req) {	
       			if(req.msg=="1"){
       				var url = "<%=path%>/bg/pdfwj";
       				 window.open(url);
       			}else{
       				
       				$.alert({
       			        title: '提示',
       			        content: '文件还未上传',
       					buttons: {
       						confirm: {
       							text: '确认',
       							btnClass: 'btn-primary',
       							action: function(){
       			                   
       							}
       						}
       					}
       			    });
       			}
       			 
       		},error: function(){ 
       			
       			
       		}
       	});
        
       }
       $('#tb_hhhtxx').bootstrapTable({
   		classes: 'table table-condensed table-hover',
   	   data:[],
   		method: 'post',
   	     dataType : 'json',        // 因为本示例中是跨域的调用,所以涉及到ajax都采用jsonp,
   	  toolbar: '#toolbar',       // 工具按钮容器
      pagination: true,                    // 是否显示分页
      sortOrder: "asc",                    // 排序方式
      queryParams: function(params) {
          var temp = {
              limit: params.limit,         // 每页数据量
              offset: params.offset,       // sql语句起始索引
              page: (params.offset / params.limit) + 1,
              sort: params.sort,           // 排序的列名
              sortOrder: params.order      // 排序方式'asc' 'desc'
          };
          return temp;
      },                                   // 传递参数
      sidePagination: "client",            // 分页方式：client客户端分页，server服务端分页
      pageNumber: 1,                       // 初始化加载第一页，默认第一页
      pageSize: 10,                        // 每页的记录行数
      pageList: [10, 25, 50, 100],         // 可供选择的每页的行数
      search: true,                      // 是否显示表格搜索，此搜索是客户端搜索
     columns: 
   		    	[
   		    	{field: 'id',title:'序号'},
   		       	{field: 'name',title:'姓名'},
   		   	{field: 'card',title:'身份证号'},
  		     {field: 'companyname',title:'公司名称'},
   		  {field: 'phone',title:'手机号'},
   		{field: 'email',title:'邮箱'},
   		{field: 'filelj',title:'申请表',
   			
   			formatter: function (value, row, index) {
              	 var result;
              	 result ='<i class="mdi mdi-file-pdf"><a onclick="showpdf(\''+row.filelj+'\')">申请表</a></i>';
              	 return result;
              }
   		},
   		{field: 'userid',title:'账号id',
   			
   			formatter: function (value, row, index) {
              	 var result;
              	 if(value==0){
              		 result = "未创建";
              	 }else{
              		 result = value;
                   		 
              	 }
              	 return result;
              }
   		},
   	    {field: 'jg',title:'审核结果',
   			
   			formatter: function (value, row, index) {
              	 var result;
              	if(value==0){
              		 result ='<a style="color:#4d5259">未审核</a>';
                  	 
              	}else if(value==1){
              		
              		 result ='<a style="color:#4d5259">审核通过</a>';
              	}else{
              		
              		 result ='<a style="color:#4d5259">未通过</a>';
              	}
              	 
              	 return result;
              }
   		},
  		{field: 'msg',title:'邮件发送情况'},
   		{
   	        field: 'operate',
   	        title: '操作',
   	        formatter: btnGroup,  // 自定义方法
   	        events: {
   	            'click .edit-btn': function (event, value, row, index) {
   	            	xzsj = row;
   	            if(row.zt != 2){
   	            	 
   	            	 $("#exampleModal").modal('show');
   	             }else{
   	            	 
   	              $.alert("数据已审核"); 
   	             }
   	         
   	                
   	            },
   	         }} ],
	    	       	  onClickCell: function(field, value, row, $element) {
   		    		
   		    	  },
   		             onLoadSuccess: function(data){
   		     	        $("[data-toggle='tooltip']").tooltip();
   		     	    
   		     	        
   		     	    
   		     	    }
   		});
     
    // 操作按钮
       function btnGroup ()
       {
           let html =
               '<a href="#!" class="btn btn-xs btn-default m-r-5 edit-btn" title="审核" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>';
           return html;
       }
       
      </script>
       </body>

</html>   